using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using WHXK;

namespace Web
{
    public partial class hyzx_news : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if(Request.Params["id"] != null)
                BindGrid(Request.Params["id"].ToString());
            }
        }

        protected void BindGrid(string id)
        {
            WHXK.NewsInfo ni = new NewsInfo();
            WHXK.NewsInfoStruct nist = new NewsInfoStruct();
            DataSet ds = new DataSet();
            if (ni.getAllNewsInfo(ref ds, " news_id = ``" + id + "``"))
            {
                if (ds.Tables[0].Rows.Count > 0)
                {
                    lbtitle.Text = ds.Tables[0].Rows[0]["news_title"].ToString();
                    lbpostuser.Text = ds.Tables[0].Rows[0]["news_postuser"].ToString();
                    lbcontent.Text = FormatBody(ds.Tables[0].Rows[0]["news_content"].ToString());
                    lbposetime.Text = DateTime.Parse(ds.Tables[0].Rows[0]["news_posetime"].ToString()).ToString("yyyy-MM-dd");
                    lbhit.Text = ds.Tables[0].Rows[0]["news_hit"].ToString();
                }
            }
            ni.initStruct(ref nist);
            nist.news_hit = Convert.ToInt32(lbhit.Text) + 1;
            ni.Modify(nist, " news_id = ``" + Request["id"].ToString() + "``");
        }
        protected string FormatBody(string sBody)
        {
            return (sBody.Replace("\n", "<br>"));

        }
    }
}
